<?php 
$link = mysql_connect('localhost', 'root', '');
//$link = mysql_connect('aecabill.accountsupportmysql.com', 'aeca', 'fArC5YyyG8NT9wdC5LXP');
if (!$link) { 
     die('There appeared to be an error while connecting to the website database: ' . mysql_error()); 
}
mysql_select_db(aeca);

//$id = $_GET['Id'];
$id = $_POST['id'];
if($id){
$wquery = "select * from tbl_whis_carriers where id= $id";
$wresult = mysql_query($wquery);
$data = mysql_fetch_array($wresult);
}
?>

<script>
  $(function() {  
   $(".whscsub").click(function() { 
     // validate and process form here
     $("#whsc_frm").validate();
     var name = 'wholeSale Data';
     var wid = $("#wid").val();
     var whs_id = $("#whls_carriers_id").val();
     var whs_name = $("#whls_carriers_name").val();
     if(whs_id != ''){
	     $.post("/aec1/pages/update_cprofile.php",{name:name,wid:wid,whs_id:whs_id,whs_name:whs_name},function(data){
	     	if(data == 0)
	     	{
	     		$("#error").text("CIC code Already Exists.Enter New CIC Code").show();
	     	}else if(data == 1){
	     		$( "#dialog:ui-dialog" ).dialog( "destroy" );
				$( "#dialog-message_u" ).dialog({
				modal: true,
				buttons: {
					Ok: function() {
						$(this).dialog( "close" );
						window.location = "index.php?page=company-mang";
					}
				}
				});
//	     		$("#success").text("The WholeSale Carrier has been Updated Successfully.").show();	
	     	}else if(data == 2){
	     		$( "#dialog:ui-dialog" ).dialog( "destroy" );
				$( "#dialog-message_i" ).dialog({
				modal: true,
				buttons: {
					Ok: function() {
						$(this).dialog( "close" );
						window.location = "index.php?page=company-mang#tabs-4";
					}
				}
				});
//	     		$("#success").text("The new WholeSale Carrier has been created.").show();	
	     	}
	     	
	     	
	     });
	     return false;
     }
   });  
 });
</script>
<!-- ui-dialog -->
<div id="dialog-message_u" title="Success Update" style="display:none;">
	<p>
		<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
		The WholeSale Carrier has been Updated Successfully.
	</p>
</div>
<div id="dialog-message_i" title="Success Update" style="display:none;">
	<p>
		<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
		The new WholeSale Carrier has been created.
	</p>
</div>
<span id='error'></span><span id='success'></span>
<fieldset>
<legend><strong><h3>WholeSale Carriers</h3></strong></legend>
<!-- <form action="index.php?page=wholesale-carriers<?if($id){?>&Id=<?=$id;}?>" method="post" id="whsc_frm"> -->
<form action="" method="post" id="whsc_frm">
<table cellpadding="3">
	<tr>
		<td><strong>CIC* :</strong></td>
		<td><input type="text" name="whls_carriers_id" value="<?=$data['whls_carriers_id'];?>" class="required" id="whls_carriers_id"/></td>
	</tr>
	<tr>
		<td><strong>IXC :</strong></td>
		<td>
		<select name="whls_carriers_name" id="whls_carriers_name" style="width:145px;">
			<option value="---" <? if($data['whls_carriers_name'] == '---'){ echo 'selected="selected"'; } else {} ?>>---</option>
			<option value="GCI" <? if($data['whls_carriers_name'] == 'GCI'){ echo 'selected="selected"'; } else {} ?>>GCI</option>
			<option value="ACS" <? if($data['whls_carriers_name'] == 'ACS'){ echo 'selected="selected"'; } else {} ?>>ACS</option>
		</select>
		</td>
	</tr>
	<tr>
		<td>&nbsp;<input type="hidden" name="adhidden" value="<?=$id?>" id="wid"/></td>
		<td><input type="submit" value="Submit" name="wsubmit" class="whscsub"/>
		<input type="button" value="Cancel" name="cancel" onclick="location.href='index.php?page=company-mang<?if(!$id){?>#tabs-4<?}?>'"/>
		</td>
	</tr>
</table>
</form>
</fieldset>